<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AddUserPost extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'password' => 'required|min:6|max:20|regex:/^[a-zA-Z0-9]{6,20}$/',
            'account' => 'required|min:6|max:25',
            'pay_pass' => 'required|min:6|max:10|regex:/^[a-zA-Z0-9]{6,10}$/'
        ];
    }

    public function messages()
    {
        return [
            'account.required' => '邮箱或手机号名称不能为空',
            'password.required' => '密码不能为空',
            'pay_pass.required' => '密码不能为空',
            'password.regex' => '密码为6到16位的字母和数字',
            'pay_pass.regex' => '密码为6到10位的字母和数字',
            'password.min' => '登录密码长度不能低于6位',
            'password.max' => '登录密码长度不能高于16位',
            'pay_pass.min' => '交易密码长度不能低于6位',
            'pay_pass.max' => '交易密码长度不能高于10位',
        ];
    }
}
